package com.danco.sn.entities;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.danco.sn.apientities.ICommunity;
import com.danco.sn.apientities.ICommunityMessage;
import com.danco.sn.apientities.IUser;

@Entity
@Table(name = "community_message")
public class CommunityMessage implements ICommunityMessage {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id_message")
	private Integer idMessage;

	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Community.class)
	@JoinColumn(name = "id_community")
	private ICommunity community;

	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = User.class)
	@JoinColumn(name = "id_user")
	private IUser user;

	@Column(name = "date_message")
	private Date messageDate;

	@Column(name = "message")
	private String textMessage;

	public Integer getIdMessage() {
		return idMessage;
	}

	public void setIdMessage(Integer idMessage) {
		this.idMessage = idMessage;
	}

	public ICommunity getCommunity() {
		return community;
	}

	public void setCommunity(ICommunity community) {
		this.community = community;
	}

	public IUser getUser() {
		return user;
	}

	public void setUser(IUser user) {
		this.user = user;
	}

	public Date getMessageDate() {
		return messageDate;
	}

	public void setMessageDate(Date messageDate) {
		this.messageDate = messageDate;
	}

	public String getTextMessage() {
		return textMessage;
	}

	public void setTextMessage(String textMessage) {
		this.textMessage = textMessage;
	}
}
